'use strict';

const Controller = require('egg').Controller;

class NewsController extends Controller {
  async getnewslist () {
    const data = this.ctx.query;
    console.log(data);
    const { ctx } = this;
    const res = await ctx.service.news.getnewslist(data);
    ctx.body = res;
  }
  async addlike () {
    const { ctx } = this;
    const data = ctx.request.body;
    const res = await ctx.service.news.addlike(data);
    ctx.body = res;
  }
  async addnew () {
    const { ctx } = this;
    const data = ctx.request.body;
    const res = await ctx.service.news.addnew(data);
    ctx.body = res;
  }
  async updatenew () {
    const { ctx } = this;
    const data = ctx.request.body;
    const res = await ctx.service.news.updatenew(data);
    ctx.body = res;
  }
  // get取消收藏
  async dellike () {
    const data = this.ctx.query;
    const { ctx } = this;
    const res = await ctx.service.news.dellike(data);
    ctx.body = res;
  }
  // get取消收藏
  async adminDellike () {
    const data = this.ctx.query;
    const { ctx } = this;
    const res = await ctx.service.news.adminDellike(data);
    ctx.body = res;
  }
  // get取消收藏
  async delnew () {
    const data = this.ctx.query;
    const { ctx } = this;
    const res = await ctx.service.news.delnew(data);
    ctx.body = res;
  }
  // get获取当前用户是否已收藏该新闻
  async isChecked () {
    const data = this.ctx.query;
    const { ctx } = this;
    const res = await ctx.service.news.isChecked(data);
    ctx.body = res;
  }
  // get获取我的收藏
  async getmylike () {
    const data = this.ctx.query;
    const { ctx } = this;
    const res = await ctx.service.news.getmylike(data);
    ctx.body = res;
  }
  // get获取我的收藏
  async getallnewlike () {
    const data = this.ctx.query;
    const { ctx } = this;
    const res = await ctx.service.news.getallnewlike(data);
    ctx.body = res;
  }
  // get获取我的收藏
  async getallproductlike () {
    const data = this.ctx.query;
    const { ctx } = this;
    const res = await ctx.service.news.getallproductlike(data);
    ctx.body = res;
  }
}

module.exports = NewsController;
